home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 9.7 KB | 351 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PRGDev.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef PRGDEV_H
- #define PRGDEV_H
-
- #ifndef SLGRDEF_H
- #include "SLGrDef.h"
- #endif
-
- #ifndef SLGDEV_H
- #include "SLGDev.h"
- #endif
-
- #ifndef FWGCONST_H
- #include "FWGConst.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef PRSHATTR_H
- #include "PRShAttr.h"
- #endif
-
- #ifndef PRGRREF_H
- #include "PRGrRef.h"
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(FWGDIOBJ_H)
- #include "FWGDIObj.h"
- #endif
-
- #ifdef SelectFont
- #undef SelectFont // Macro in Windowsx.h
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWREFCNT_H
- #include "FWRefCnt.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class ODShape;
- class FW_CPoint;
- class FW_CRect;
- class FW_CPlatformRect;
- class FW_CPlatformPoint;
-
- struct FW_SGraphicContext;
-
- //========================================================================================
- // Shape Types
- //========================================================================================
-
- enum FW_EPrivShapeCategories
- {
- #ifdef FW_BUILD_MAC
- FW_kLineShape, // Line
- FW_kGeometricShape, // Rect, Oval, Arc, RoundRect, Region
- FW_kTypographicShape, // Text
- FW_kImageShape // Bitmap, Picture
- #endif
- #ifdef FW_BUILD_WIN
- FW_kGeometricShapeWithInvert, // Rect, Region
- FW_kGeometricShape, // Line, RoundRect, Oval, Arc
- FW_kTypographicShape, // Text
- FW_kImageShape // Bitmap, Picture
- #endif
- };
-
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- struct FW_SGraphicContext;
-
- //========================================================================================
- // struct FW_SPrivDeviceState
- //========================================================================================
-
- struct FW_SPrivDeviceState
- {
- #ifdef FW_BUILD_WIN
- POINT fWindOrg;
- WORD fMapMode;
- #endif
- #ifdef FW_BUILD_MAC
- // ----- if our port is not the current port fPreviousPlatformCanvas != NULL -----
- ODPlatformCanvas fPreviousPlatformCanvas;
-
- // ----- if our port was the current port (fPreviousPlatformCanvas==NULL) save its state below -----
- ODRgnHandle fClip;
- Point fOrigin;
-
- FW_Boolean fSuspended;
-
- FW_SGraphicContext* fSavedContext;
- #endif
- };
-
- //========================================================================================
- // struct FW_SPrivSuspendResumeState
- //========================================================================================
-
- #ifdef FW_BUILD_WIN
- struct FW_SPrivSuspendResumeState
- {
- int fSavedDC;
- FW_SGraphicContext* fSavedContext;
- };
- #endif
-
- #ifdef FW_BUILD_MAC
- #define FW_SPrivSuspendResumeState FW_SPrivDeviceState
- #endif
-
- //========================================================================================
- // class FW_CPrivGraphicsDevice
- //========================================================================================
-
- class FW_CPrivGraphicsDevice : public FW_CPrivGrRefObj
- {
- //---------------------------------------------------------------------------------------
- // Constructor/Destructor
- //
- public:
- FW_DECLARE_AUTO(FW_CPrivGraphicsDevice)
-
- FW_CPrivGraphicsDevice(ODCanvas* odCanvas);
- FW_CPrivGraphicsDevice(ODPlatformCanvas platformCanvas);
-
- virtual ~FW_CPrivGraphicsDevice();
-
- //---------------------------------------------------------------------------------------
- // API
- //
- public:
- ODPlatformCanvas GetPlatformCanvas() const;
- operator ODPlatformCanvas() const;
-
- ODCanvas* GetODCanvas() const;
-
- FW_SPrivDeviceState* OpenDevice(Environment *ev, FW_SGraphicContext* context);
- void CloseDevice(Environment *ev, FW_SPrivDeviceState* deviceState);
-
- ODRgnHandle GetClip() const; // return a copy
- void GetClipRect(FW_CPlatformRect& clipRect) const;
-
- void SetClip(Environment* ev, ODRgnHandle clipRegion); // Use a copy
- void SetClipRect(const FW_CPlatformRect& clipRect);
- void IntersectClipRect(Environment* ev, const FW_CPlatformRect& clipRect);
-
- void SetOrigin(Environment* ev, FW_CPlatformPoint origin);
-
- FW_SPrivDeviceState* GetState();
-
- FW_SPrivSuspendResumeState* Suspend();
- void Resume(FW_SPrivSuspendResumeState *suspendResumeState);
-
- void CanvasChanged(Environment *ev, ODCanvas* odCanvas);
- void MappingChanged(Environment* ev);
-
- // ----- Return the resolution in dpi -----
- FW_CPoint GetResolution() const;
- void SetResolution(FW_Fixed x, FW_Fixed y);
-
- void UpdateOriginForContext(Environment* ev);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- ODCanvas* fODCanvas; // Might be NULL
- ODPlatformCanvas fPlatformCanvas;
-
- short fOpenDeviceCount;
-
- FW_CPoint fResolution;
-
- FW_Boolean fSuspended;
-
- FW_SGraphicContext* fContext;
-
- //----------------------------------------------------------------------------------------
- // Platform Specific API
- //
- #ifdef FW_BUILD_WIN
- public:
- void SelectFont(const FW_HFont font, FW_Boolean scale);
-
- FW_Boolean IsMetaFileCanvas() const;
-
- // ----- Settings -----
- void SelectInkAndFont(const FW_HInk ink,
- const FW_HFont font);
- FW_Boolean SelectInkAndStyle(const FW_HInk ink,
- const FW_HStyle style,
- FW_EPrivShapeCategories shapeType,
- FW_ERenderVerbs renderVerb);
-
- void SetTextColor(COLORREF textColor);
- void SetBkColor(COLORREF bkColor);
-
- protected:
- // ----- We don't bother doing any caching for those, they should be pretty fast -----
- void SetDrawingMode(int drawingMode)
- {::SetROP2(fPlatformCanvas, drawingMode);}
- void SetBkMode(int bkMode)
- {::SetBkMode(fPlatformCanvas, bkMode);}
- #endif
- #ifdef FW_BUILD_MAC
- public:
- // ----- Settings -----
- void SelectInk(const FW_HInk ink,
- FW_EPrivShapeCategories shapeCategory,
- FW_ERenderVerbs renderVerb);
- void SelectStyle(const FW_HStyle style,
- FW_TransferModes transferMode,
- FW_Boolean& styleIsDash,
- FW_Boolean& styleIsHairline);
- void SelectFont(const FW_HFont font,
- FW_Boolean scale);
-
- void SetInGrafPort();
- void ResetSettings();
-
- // Values for fChangeFlag
- enum
- {
- FW_kForeColorChanged = 0x0001,
- FW_kBackColorChanged = 0x0002,
- FW_kHiliteColorChanged = 0x0004,
- FW_kPatternChanged = 0x0008
- };
-
- void SetForeColor(const FW_CColor& foreColor)
- {fForeColor = foreColor; fChangeFlag |= FW_kForeColorChanged;}
- void SetBackColor(const FW_CColor& backColor)
- {fBackColor = backColor; fChangeFlag |= FW_kBackColorChanged;}
- void SetHiliteColor(const FW_CColor& hiliteColor)
- {fHiliteColor = hiliteColor; fChangeFlag |= FW_kHiliteColorChanged;}
- void SetPattern(const FW_HPattern pattern);
- void SetPenSize(short hPenSize, short vPenSize)
- {fHPenSize = hPenSize; fVPenSize = vPenSize;}
- void SetFontID(short fontID)
- {fFontID = fontID;}
- void SetFontSize(short fontSize)
- {fFontSize = fontSize;}
- void SetFontStyle(Style fontStyle)
- {fFontStyle = fontStyle;}
- void SetPenMode(short penMode)
- {fPenMode = penMode;}
- void SetTextMode(short textMode)
- {fTextMode = textMode;}
-
- private:
- void MacBeginPostScriptClip(Environment* ev, RgnHandle rgn);
- void MacEndPostScriptClip();
- #endif
-
- //----------------------------------------------------------------------------------------
- // Platform Specific Data Members
- //
- #ifdef FW_BUILD_WIN
- public:
- // ----- Settings -----
- COLORREF fTextColor;
- COLORREF fBkColor;
- FW_CPlatformPoint fPenSize; // Used for frame with brush
-
- // ----- Brush/Pen/Font -----
- FW_CPrivGDIPen fGDIPen;
- FW_CPrivGDIBrush fGDIBrush;
- FW_CPrivGDIFont fGDIFont;
- #endif
- #ifdef FW_BUILD_MAC
- public:
- // ----- Device Settings -----
- FW_CColor fForeColor;
- FW_CColor fBackColor;
- FW_CColor fHiliteColor;
- FW_PPrivPattern fPattern;
- short fHPenSize;
- short fVPenSize;
- short fFontID;
- short fFontSize;
- Style fFontStyle;
- short fPenMode;
- short fTextMode;
-
- private:
- unsigned short fChangeFlag;
-
- // ----- PostScript clipping
- FW_Boolean fMacPostScriptClip;
- #endif
- };
-
- //---------------------------------------------------------------------------------------
- // FW_CPrivGraphicsDevice::GetODCanvas
- //---------------------------------------------------------------------------------------
- inline ODCanvas* FW_CPrivGraphicsDevice::GetODCanvas() const
- {
- return fODCanvas;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPrivGraphicsDevice::GetPlatformCanvas
- //---------------------------------------------------------------------------------------
- inline ODPlatformCanvas FW_CPrivGraphicsDevice::GetPlatformCanvas() const
- {
- return fPlatformCanvas;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CPrivGraphicsDevice::operator ODPlatformCanvas
- //---------------------------------------------------------------------------------------
- inline FW_CPrivGraphicsDevice::operator ODPlatformCanvas() const
- {
- return fPlatformCanvas;
- }
-
- #endif
-